// pages/myKeep/detail.js
const app = getApp();
var utils = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;

    var sucFunc = function (that, res) {
      var zAnswer = '';
      var yAnswer = '';
      yAnswer = res.data.youAnswer.indexOf(res.data.optiona) != -1 ? yAnswer + 'A' : yAnswer;
      yAnswer = res.data.youAnswer.indexOf(res.data.optionb) != -1 ? yAnswer + 'B' : yAnswer;
      yAnswer = res.data.youAnswer.indexOf(res.data.optionc) != -1 ? yAnswer + 'C' : yAnswer;
      yAnswer = res.data.youAnswer.indexOf(res.data.optiond) != -1 ? yAnswer + 'D' : yAnswer;
      if (res.data.answer.indexOf(res.data.optiona) != -1) {
        zAnswer = zAnswer + 'A';
        res.data.xa = 2;
      }else{
        res.data.xa = res.data.youAnswer.indexOf(res.data.optiona) != -1?3:1
      }
      if (res.data.answer.indexOf(res.data.optionb) != -1) {
        zAnswer = zAnswer + 'B'
        res.data.xb = 2
      } else {
        res.data.xb = res.data.youAnswer.indexOf(res.data.optionb) != -1 ? 3 : 1
      }
      if (res.data.answer.indexOf(res.data.optionc) != -1) {
        zAnswer = zAnswer + 'C'
        res.data.xc = 2
      } else {
        res.data.xc = res.data.youAnswer.indexOf(res.data.optionc) != -1 ? 3 : 1
      }
      if (res.data.answer.indexOf(res.data.optiond) != -1) {
        zAnswer = zAnswer + 'D'
        res.data.xd = 2
      } else {
        res.data.xd = res.data.youAnswer.indexOf(res.data.optiond) != -1 ? 3 : 1
      }
      res.data.zAnswer = zAnswer;
      res.data.yAnswer = yAnswer
      that.setData({
        item: res.data
      })
    }
    var data = { id: options.id }
    utils.wxRequest(that, app.d.path, "Profession/myErrorDetail", data, sucFunc);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})